
package Q448

import java.util.ArrayList
import kotlin.math.abs


/**
 * 找到所有数组中消失的数字
 * @author 23737
 * @date 2022.5.11
 */
fun main(){

}

class Solution {
    fun findDisappearedNumbers(nums: IntArray): List<Int> {
        val results: MutableList<Int> = ArrayList()
        for (i in nums.indices) {
            if (nums[abs(nums[i]) - 1] > 0) {
                nums[abs(nums[i]) - 1] = -nums[abs(nums[i]) - 1]
            }
        }
        for (i in nums.indices) {
            if (nums[i] > 0) {
                results.add(i + 1)
            }
        }
        return results
    }
}